{%if setting.type ==1%}
<input type="hidden" name="editor" value="1">
<textarea class="form-control " name="{{name}}" placeholder="请输入内容...">{{value | safe}}</textarea>
<script type="text/javascript">
    $('textarea[name="{{name}}"]').height('{{setting.height}}');
</script>

{%elif setting.type == 2%}

{% if setting.wysiwyg == 1%}
<input type="hidden" name="editor" value="2_1">
<!-- 加载编辑器的容器 -->
<script id="Editor_{{name}}" name="{{name}}" style="width: 100%; height: {{setting.height}}" type="text/plain">{{value|d('请输入内容...',true) | safe}}</script>
<script type="text/javascript" charset="utf-8" src="/static/admin/js/udeitor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/admin/js/udeitor/ueditor.all.min.js"> </script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="/static/admin/js/udeitor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
    UE.getEditor('Editor_{{name}}', {
        theme:"default", //皮肤
        lang:'zh-cn', //语言
        serverUrl: '/ext/editor/adminueditor'
    });
</script>
{% elif setting.wysiwyg == 2%}
<input type="hidden" name="editor" value="2_2">
<textarea  name="{{name}}" style="display: none">{{value|d("<p>请输入内容...</p>",true) | safe}}</textarea>
<div id="Editor_{{name}}" >
    {{value|d('<p>请输入内容...</p>',true) | safe}}
</div>

<!-- 注意， 只需要引用 JS，无需引用任何 CSS ！！！-->
<script type="text/javascript" src="/static/admin/js/wangEditor/wangEditor.min.js"></script>
<script type="text/javascript">
    var E = window.wangEditor
    var editor = new E('#Editor_{{name}}')
    // 或者 var editor = new E( document.getElementById('#editor') )
    editor.customConfig.uploadImgServer = '/ext/attachment/adminfile/uploadpic?type=wangEditor';
    editor.customConfig.uploadFileName = 'file';
    editor.customConfig.uploadImgMaxLength = 1;
    editor.customConfig.onchange = function (html) {
        // html 即变化之后的内容
        $('textarea[name="{{name}}"]').text(html)
    }
    editor.create();
    $('div.w-e-text-container').css({'height': '{{setting.height}}'});
</script>
{% endif %}
{%elif setting.type == 3%}
<input type="hidden" name="editor" value="3">
<link rel="stylesheet" href="/static/admin/editormd/editormd.min.css" />
<div id="Editor_{{name}}"><textarea name="{{name}}" style="display:none;">{{value|d('请输入内容...',true) | safe}}</textarea></div>
<script src="/static/admin/editormd/editormd.min.js"></script>
<script type="text/javascript">
    var testEditor;

    $(function() {
            testEditor = editormd("Editor_{{name}}", {
                width: "100%",
                height: '{{setting.height}}',
                path : '/static/admin/editormd/lib/',
                codeFold : true,
                //syncScrolling : false,
                saveHTMLToTextarea : true,    // 保存 HTML 到 Textarea
                searchReplace : true,
                //htmlDecode : "style,script,iframe|on*",            // 开启 HTML 标签解析，为了安全性，默认不开启
                //toolbar  : false,             //关闭工具栏
                //previewCodeHighlight : false, // 关闭预览 HTML 的代码块高亮，默认开启
                emoji : true,
                taskList : true,
                tocm            : true,         // Using [TOCM]
                tex : true,                   // 开启科学公式TeX语言支持，默认关闭
                //flowChart : true,             // 开启流程图支持，默认关闭
                //sequenceDiagram : true,       // 开启时序/序列图支持，默认关闭,
                //dialogLockScreen : false,   // 设置弹出层对话框不锁屏，全局通用，默认为true
                //dialogShowMask : false,     // 设置弹出层对话框显示透明遮罩层，全局通用，默认为true
                //dialogDraggable : false,    // 设置弹出层对话框不可拖动，全局通用，默认为true
                //dialogMaskOpacity : 0.4,    // 设置透明遮罩层的透明度，全局通用，默认值为0.1
                //dialogMaskBgColor : "#000", // 设置透明遮罩层的背景颜色，全局通用，默认为#fff
                imageUpload : true,
                imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
                imageUploadURL : "/ext/attachment/adminfile/uploadpic?type=editormd",
                {%if setting.markdownpreview ==0%}
                watch : false,                // 关闭实时预览
                {%endif%}
            });
            testEditor.config({
                tocDropdown   : true,
                tocTitle      : "目录 Table of Contents",
            });

    });
</script>

{%endif%}
